package com.centsuse.my_redis.es.entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @author bobo
 */
@Document(indexName = "books") // 索引名
public class Book {
    @Id
    private String id;

    @Field(type = FieldType.Text, analyzer = "ik_max_word") // 使用IK中文分词
    private String title;

    @Field(type = FieldType.Keyword) // 精确匹配
    private String author;

    // Getter & Setter
    @Field(type = FieldType.Text, analyzer = "ik_max_word") // 使用IK中文分词
    private String context;

    public Book() {
    }

    public Book(String id, String title, String author, String context) {
        this.id = id;
        this.title = title;
        this.author = author;
        this.context = context;
    }
}